<?php

/*
 * Copyright 2008 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#namespace tehframework\validation;

interface Validator
{
	/**
	 * Determines whether this validator can validate the specified value.
	 * 
	 * @param  mixed $value
	 *         A value to bo validated.
	 * @return bool
	 *         TRUE if this validator can validate the specified value;
	 *         FALSE otherwise.
	 */
	function supports($value);
	
	/**
	 * Validates the specified {@link $target target} value.
	 * 
	 * The supplied target value must be of type for which {@link supports()}
	 * method typically has (or would) return TRUE.
	 * 
	 * The supplied {@link Errors $errors} instance can be used to report
	 * any resulting validation errors.
	 * 
	 * @param  mixed $target
	 *         The object that is to be validated.
	 * @param  ValidationErrors $errors
	 *         Contextual state about the validation process.
	 */
	function validate(&$target, ValidationErrors $errors);
}